package com.me.mysqladmin.entity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TableData implements Serializable {
	private static final long serialVersionUID = 1L;
	
	// 当前位置、字段、字段值的映射
	// 映射规则如下：
	// {"databaseName":"mis","tableName":"member","keys":["account","password"],"values":["342535","435"]}
	private Map<String, Object> map;
	
	// 当前数据库
	private String databaseName;
	
	// 当前表名
	private String tableName;
	
	// 字段
	private List<String> keys;
	
	// 值
	private List<Object> values;
	
	// 当前记录的主键信息
	private String pkName;
	private Object pkValue;

	public Map<String, Object> getMap() {
		Map<String, Object> map = new HashMap<>();
		map.put("location", getDatabaseName() + "." + getTableName());
		map.put("keys", getKeys());
		map.put("values", getValues());
		map.put("pkName", getPkName());
		map.put("pkValue", getPkValue());
		return map;
	}

	public void setMap(Map<String, Object> map) {
		this.map = map;
	}

	public List<String> getKeys() {
		return keys;
	}

	public void setKeys(List<String> keys) {
		this.keys = keys;
	}

	public List<Object> getValues() {
		return values;
	}

	public void setValues(List<Object> values) {
		this.values = values;
	}

	public String getDatabaseName() {
		return databaseName;
	}

	public void setDatabaseName(String databaseName) {
		this.databaseName = databaseName;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}
	
	public String getPkName() {
		return pkName;
	}

	public void setPkName(String pkName) {
		this.pkName = pkName;
	}
	
	public Object getPkValue() {
		return pkValue;
	}

	public void setPkValue(Object pkValue) {
		this.pkValue = pkValue;
	}

	@Override
	public String toString() {
		return "TableData [map=" + map + "]";
	}
}
